package org.example.datastructure.ch8;

public class MySearch {
    int seqSearch(MySet[] data,int x){
        int n = data.length;
        for(int i=0;i<n;i++){
            if((int)data[i].value==x) return i;
        }
        return -1;
    }
    int binSearch(MySet[] data,int x){
        int low = 0;
        int high = data.length;
        int mid = 0;
        while(low<=high){
            mid = (low+high)/2;
            if((int)data[mid].value==x) return mid;
            if(x<(int)data[mid].value) high = mid-1;
            else low = mid+1;
        }
        return -1;
    }
}

class MySet<String,Integer>{
    public String key;
    public Integer value;

    MySet(String key, Integer value) {
        this.key = key;
        this.value = value;
    }
}
